var cid=0;
// //从作用域获取
// var venueName="死亡健身";
// var venueId=1;
// //内容嵌入的场馆名链接
// var senderName="<a href='http://localhost:8080/venue/homePage.html'></a>";
var cd=new Vue({
	el:"#cd",
	data:{
		vid:0,
		venue:{},
		avatar:"",
		nickname:"",
		phoneNumber:"",
		styleName:"",
		address:"",
		isBand:"",
		isPrivate:"",
		isFull:"",
		isAccept:"",
		price:"",
		salary:"",
		content:""
	},
	mounted(){
		axios.get("/venue/session").then(res=>{
			console.info("sessionVenue:")
			console.info(res.data.data);
			this.vid=res.data.data.vid;
			axios.get("/venue/find/"+this.vid).then(e=>{
				console.info(e.data.data);
				this.venue=e.data.data;
				// venue=e.data.data;
				console.info(this.venue)

			}).catch(er=>{
				console.info(er)
			});
		}).catch(err=>{
			console.info(err)
		});

		let url=window.location.href;
		console.info("url:"+url);
		cid=url.substring(url.lastIndexOf("=")+1);
		console.info("cid:"+cid);
		console.info("this:")
		console.info(this)
		//不用之前的this绑定不了，先在data属性是赋几个值就知道了
		let that=this;
		axios.get("/coach/coachById/"+cid).then(function (response) {
			console.info("coach:");
			console.info(response);
			console.info("this:")
			console.info(this)
			let coach=response.data.data;
			that.avatar=coach.avatar;
			console.info("avatar:"+that.avatar);
			that.nickname=coach.nickname;
			console.info("nickname:"+that.nickname);
			that.phoneNumber=coach.phoneNumber;
			that.address=coach.address;
			that.isBand=coach.isBand==="1"?"是":"否";
			that.isAccept=coach.isAccept==="1"?"是":"否";
			that.isPrivate=coach.isPrivate==="1"?"是":"否";
			that.isFull=coach.isFull==="1"?"是":"否";
			that.price=coach.price;
			that.salary=coach.salary;
			that.styleName=coach.styleName;
		}).catch(function (err) {
			console.info(err);
		})
	},
	methods:{
		invite:function () {
			axios({
				method:"post",
				url:"/message/add",
				data: {
					"sender":this.venue.vid,
					"target":cid,
					"content":this.venue.nickname+"给你发来签约邀请！",
					"purpose":"2"
				}
			}).then(response=>{
				if (response.data.code === 200 ){
					alert("发送邀请成功")
				}else{
					alert("发送邀请出错")
				}
			}).catch(err=>{
				console.info(err)
			})
		}
	}
});